$(function () {
    obj.init();
});

var obj = new function () {
    return {
        dataGrid: null,
        init: function () {
            this.dataGrid = new xhDataGrid($('#list'), 'lm/goods/getGoodsStat');
            this.dataGrid.parseToolbar().init();
            xhExtra.clearLoadSuccess(this.dataGrid);
            this.listener();
        },
        listener: function () {
            var $this = this;
            //查询
            xhTool.bindDocKeyDown(
                $('#bt_list_search').click(function () {
                    $this.funObj().searchList();
                })
            );
            //双击
            $this.dataGrid.onDblClickRow = function(rowIndex, rowData){
                var id = rowData['iId'];
                var name = rowData['sGoodsName'];
                $this.funObj().getGoodsDetail(id,name);
            };
        },
        funObj: function () {
            var $this = this;
            return {
                searchList: function () {
                    $this.dataGrid.reload({
                        search: {
                            vague: xhExtra.getValue($('#list_vague'))
                        },
                        type: xhExtra.getValue($('#list_search_type'))
                    })
                },
                getGoodsDetail: function (id,name) {
                    window.top.xhTop.showModal({
                        title: name + '库存明细',
                        content: xhTool.getFrameString('lm/goods/goodsDetailData?goodsId='+id, null, 600),
                        size: 'lg',
                        backClose: false
                    });
                }
            }
        }
    }
};